package dhm.com.hpx.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import dhm.com.hpx.R;
import dhm.com.hpx.entity.GetIndustryFollowBean;

/**
 * Created by admin
 * 2019/4/29
 * 所有订单适配器
 */
public class IndustryAdapter extends RecyclerView.Adapter<IndustryAdapter.ViewHolder>{

    private Context context;


    List<GetIndustryFollowBean.DataBean> list = new ArrayList<>();

    public IndustryAdapter(Context context) {
        this.context = context;
    }


    public void setList(List<GetIndustryFollowBean.DataBean> list) {
        this.list = list;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        ViewHolder viewHolder;
        View view = LayoutInflater.from(context).inflate(R.layout.item_industry, null);
        viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull final ViewHolder viewHolder, final int i) {
        viewHolder.name.setText(list.get(i).getIndustry_name());
        viewHolder.cancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onClick.item(i);
            }
        });

    }
    @Override
    public int getItemCount() {
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        public TextView name;
        public ImageView cancle;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            name = itemView.findViewById(R.id.name);
            cancle = itemView.findViewById(R.id.cancle);
        }
    }

    private OnClick onClick;

    public void setdeleteClick(OnClick onClick) {
        this.onClick = onClick;
    }

    public interface OnClick {
        void item(int posttion);
    }

    private OnIntentClick onIntentClick;

    public void setaddClick(OnIntentClick onClick) {
        this.onIntentClick = onClick;
    }

    public interface OnIntentClick {
        void item(int position);
    }


}

